<?php
  session_start();

  if(!isset($_SESSION['isLogged'])){
    header('Location: index.php');
  }
  $now=time();
  if(isset($_SESSION['isLogged']) && ($now>$_SESSION['expired'])){
    session_unset();
    session_destroy();
    header('Location: index.php');
  }

?>

<div class="panel panel-primary">
    <div class="panel-heading">
        <h3>Daftar Usulan</h3>
    </div>
    <div class="panel-body">
    <form method="post" action="controller/cont.usulan_peg.php" id="frm_cetak">
    <input type="hidden" id="id_usulan_cetak" name="id_usulan_cetak" />
    <input type="hidden" id="aksi_usulan_cetak" name="aksi_usulan_cetak" />
        <table cellpadding="0" cellspacing="0" border="0" class="datatable table table-condensed table-bordered table-hover col-lg-offset-0" id="list_usulan">
            <thead>
                <tr>
                    <th>Tanggal Usulan</th>
                    <th>Jenis Cuti</th>
                    <th>Keperluan</th>
                    <th>Tanggal Cuti</th>
                    <th>Hapus</th>
                    <th>Ubah</th>
                    <th>Cetak</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
        <input type="button" id="cetak" name="cetak" value="cetak" style="display:none;">
    </form>
        <a data-toggle="modal" href="#myModal" class="btn btn-primary btn-sm navbar-left" onclick="buat()">Buat Usulan</a>
        <div id="error" class="alert alert-danger">...</div>
        <div id="success" class="alert alert-success">...</div>
    </div>
</div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="clear_input_usulan()">&times;</button>
                <h4 class="modal-title" id="judul_modal">Daftar Usulan</h4>
            </div>
            <div id="modale" class="modal-body">
                <table class="table table-condensed table-bordered">
                    <form role="form" class="form-horizontal" id="usulan_peg_frm" method="post">
                        <input type="hidden" class="form-control" id="id_usulan_peg">
                        <tr>
                            <td width="35">
                        <div class="form-group">
                            <label for="nomer">NIP</label>
                            </td>
                            <td width="85">
                            <input type="text" class="form-control" disabled="disabled" id="nip_peg">
                        </div>
                        </td>
                        </tr>
                        <tr>
                            <td width="35">
                        <div class="form-group">
                            <label for="nomer">NIP Atasan</label>
                            </td>
                            <td width="85">
                            <input type="text" class="form-control" id="nip_atasan">
                        </div>
                        </td>
                        </tr>
                        <tr>
                            <td width="35">
                        <div class="form-group">
                            <label for="level">Jenis Cuti</label>
                            </td>
                            <td width="85">
                            <select class="form-control" id="id_cuti_peg">
                                
                            </select>
                        </div>
                        </td>
                        </tr>
                        <tr>
                            <td width="35">
                        <div class="form-group">
                            <label for="level">Jenis Ijin</label>
                            </td>
                            <td width="85">
                            <select class="form-control" id="id_tujuan_peg">
                                <option value="1">Ibadah</option>
                                <option value="2">Berobat</option>
                                <option value="3">Wisata</option>
                                <option value="4">Dinas</option>
                                <option value="5">Lain-lain</option>
                            </select>
                        </div>
                        </td>
                        </tr>
                        <tr>
                            <td width="35">
                        <div class="form-group">
                            <label for="tgl">Tgl Mulai</label>
                            </td>
                            <td width="85">
                            <div class="controls">
                                <div class="input-group">
                                    <input id="tgl_mulai" type="text" class="date-picker form-control" />
                                    </label>
                                </div>
                            </div>
                        </div>
                        </td>
                        </tr>
                        <tr>
                            <td width="35">
                        <div class="form-group">
                            <label for="tgl">Tgl Selesai</label>
                            </td>
                            <td width="85">
                            <div class="controls">
                                <div class="input-group">
                                    <input id="tgl_selesai" type="text" class="date-picker form-control" />
                                    </label>
                                </div>
                            </div>
                        </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                        <a data-dismiss="modal" type="submit" class="btn btn-warning btn-sm" onclick="clear_input_peg()">Batal</a>
                        <button type="submit" class="btn btn-primary btn-sm" id="btn_simpan_peg">Simpan</button>   
                        <button type="submit" class="btn btn-primary btn-sm" id="btn_simpan_ubah_peg" style="display: none;">Simpan</button>
                            </td>
                        </tr>
                    </form>
                    </table>
            </div>
            <div class="modal-footer" id="btn_group_peg">
                <button type="submit" class="btn btn-danger" data-dismiss="modal">Tutup</button>
                <div id="error2" class="alert alert-danger">...</div>
                <div id="success2" class="alert alert-success">...</div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>

<script type="text/javascript" src="js/usulan_peg.js" ></script>

<script type="text/javascript"> 

        $(".date-picker").datepicker({
            format: 'yyyy-mm-dd',
            weekStart: 1,
        });

</script>